package com.ssn.composite.file;

import java.util.ArrayList;
import java.util.List;

public class Dir implements Component{
    private String name;
    private List<Component> components;
    Dir(String name){
        this.name = name;
        components = new ArrayList<>();
    }
    @Override
    public void add(Component component) {
        components.add(component);
    }

    @Override
    public void del(Component component) {
        components.remove(component);
    }

    @Override
    public void click() {
        System.out.println("点击：" + name);
        System.out.println(components.toString());
    }

    @Override
    public String toString() {
        return "Dir{" +
                "name='" + name + '\'' +
                '}';
    }
}
